package com.thekernel.youdaoyun.mapper;

import com.thekernel.youdaoyun.YoudaoyunApplication;
import com.thekernel.youdaoyun.bean.Star;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Date;

/**
 * @Author TheKernel
 * @Date 2019/9/20 3:53 下午
 * @Version 1.0
 * @Description 测试 StarMapper
 */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = YoudaoyunApplication.class)
public class testStarMapper {

    @Autowired
    private StarMapper starMapper;

    @Test
    public void testAddStar() {
        Star star = new Star();
        star.setStarNote(1);  // 测试笔记
        star.setStarUser(1);  // 测试用户
        star.setStatus(Boolean.TRUE);
        star.setCreateTime(new Date());

        Assert.assertEquals(1, this.starMapper.add(star));
    }

    @Test
    public void testQueryStarByStarId() {
        long starId = 1;
        long starNote = 1;
        long starUser = 1;

        Star star = this.starMapper.queryStarByStarId(starId);

//        Assert.assertEquals(starId, star.getStarId());
//        Assert.assertEquals(starNote, star.getStarNote());
//        Assert.assertEquals(starUser, star.getStarUser());
    }

    @Test
    public void testCancelStarByStarId() {
        long starId = 6;

        Assert.assertEquals(1, this.starMapper.cancelStarByStarId(starId));
    }

}
